Couldn't guess out why you need a class to do the same! Still, here it is...
You can get like this:
DataTable dt = (DataTable)GridView1.DataSource;
If you want to make some changes while porting the data, you have to loop through. You have to manually create columns first, then loop through all the rows.
DataTable dt = new DataTable();
dt.Columns.Add();
foreach(GridViewRow gvr in GridView1.Rows)
{
DataRow dr = dt.NewRow();
for(int i = 0; i < gvr.Rows.Count; ++i)
{
dr[i] = gvr.Cells[i].Text;
}
}
Now if you want, you can put this piece of code in a class and expose it. Call it when you need to.